package com.ssmdemo01.utils;

import lombok.Data;

@Data
public class Result<T> {

    private Integer code = 200;

    private String message = "ok";

    private T data;

    public static Result<?> ok() {
        return new Result<>();
    }

    public static <T> Result<T> okData(T data) {
        Result<T> result = new Result<>();
        result.setData(data);
        return result;
    }

    public static <T> Result<T> okData(T data, String message) {
        Result<T> result = new Result<>();
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> build(Integer code, T data, String message) {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result<?> failure(Integer code, String message) {
        Result<?> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    // getter and setter
}
